#region COPYRIGHT
//--------------------------------------------------------------------------------
// <copyright file="CameraRegion.cs" company="starLiGHT Entertainment Studios">
//    Copyright (c) 2007, 2008, 2009, 2010
//       Roland Rosenkranz (Glatzemann@email.de)
// </copyright>
// <license>
//   This file is part of starLiGHT.Render.
//
//   starLiGHT.Render is free software: you can redistribute it and/or modify
//   it under the terms of the GNU Lesser General Public License as published by
//   the Free Software Foundation, either version 3 of the License, or
//   (at your option) any later version.
//
//   starLiGHT.Core is distributed in the hope that it will be useful,
//   but WITHOUT ANY WARRANTY; without even the implied warranty of
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//   GNU Lesser General Public License for more details.
//
//   You should have received a copy of the GNU Lesser General Public License
//   along with starLiGHT.Render. If not, see http://www.gnu.org/licenses/.
//    
//   ADDITIONAL (commercial) LICENSES for starLiGHT.Render are available on request.
// </license>
// <version>
// **************[ starLiGHT.Engine SVN ]**********************
// * $Rev:: 620                   $:  Revision of last commit *
// * $Author:: unknown            $:  Author of last commit   *
// * $Date:: 2010-12-07 15:23:58 #$:  Date of last commit     *
// ************************************************************
// </version>
//--------------------------------------------------------------------------------
#endregion

namespace starLiGHT.Camera.TwoD
{
    #region Using Statements
    using System;
    using System.Collections.Generic;
    using System.Text;
    using Microsoft.Xna.Framework;

    #endregion

    [Flags]
    public enum CameraRegionConstraints
    {
        NONE = 0,
        LEFT = 1,
        RIGHT = 2,
        TOP = 4,
        BOTTOM = 8,
        ALL = LEFT | RIGHT | TOP | BOTTOM,
        HORIZONTAL = TOP | BOTTOM,
        VERTICAL = LEFT | RIGHT,
    }

    public class CameraRegion
    {
        private RectangleF bounds;
        private CameraRegionConstraints constraints;
        private string name;

        public CameraRegion(string name, float x, float y, float width, float height, CameraRegionConstraints constraints)
            : this(x, y, width, height)
        {
            this.name = name;
            this.constraints = constraints;
        }

        public CameraRegion(float x, float y, float width, float height)
        {
            this.bounds = new RectangleF(new Vector2(x, y), width, height);
            ////constraints = CameraRegionConstraints.NONE;
            ////LastActive = 0L;
        }

        public RectangleF Bounds
        {
            get
            {
                return this.bounds;
            }
        }

        public long LastActive
        {
            get;
            set;
        }

        public float? MinX
        {
            get
            {
                if ((this.constraints & CameraRegionConstraints.LEFT) == CameraRegionConstraints.LEFT)
                {
                    return this.bounds.TopLeft.X;
                }
                else
                {
                    return null;
                }
            }
        }

        public float? MinY
        {
            get
            {
                if ((this.constraints & CameraRegionConstraints.TOP) == CameraRegionConstraints.TOP)
                {
                    return this.bounds.TopLeft.Y;
                }
                else
                {
                    return null;
                }
            }
        }

        public float? MaxX
        {
            get
            {
                if ((this.constraints & CameraRegionConstraints.RIGHT) == CameraRegionConstraints.RIGHT)
                {
                    return this.bounds.BottomRight.X;
                }
                else
                {
                    return null;
                }
            }
        }

        public float? MaxY
        {
            get
            {
                if ((this.constraints & CameraRegionConstraints.BOTTOM) == CameraRegionConstraints.BOTTOM)
                {
                    return this.bounds.BottomRight.Y;
                }
                else
                {
                    return null;
                }
            }
        }
    }
}
